package org.example.route.task;

import lombok.extern.slf4j.Slf4j;
import org.example.route.constant.StationRouteConstant;
import org.example.route.mapper.PriceMapper;
import org.example.route.mapper.StationRouteMapper;
import org.example.route.model.pojo.StationRoute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
 *
 * 过了一段时间之后车站的消息自动删除
 *
 * **/
@Component
@Slf4j

public class StationRouteTask {
    @Autowired
    private StationRouteMapper stationRouteMapper;


    //每半天执行一次
    @Scheduled(cron = "0 0 * * * ?")
    @Transactional
    public void processOutDateStationRoute()
    {
        List<StationRoute> stationRoutes = stationRouteMapper.listOutDateStationRoute(StationRouteConstant.STATUS_NORMAL,LocalDateTime.now());
        stationRoutes.stream().forEach(
                stationRoute -> {

                    stationRoute.setStatus(StationRouteConstant.STATUS_DELETED);


                }


        );

    }


}
